#-*-coding:utf-8-*-
import hou
class Animation(object):
    def __init__(self):
        super(Animation,self).__init__()

    def setKeying_AutoKeyAddKeyframesOnParameterChange(self,bool):
        if bool == True:
            hou.setPreference('general.nopending.val','1')
            #print('1')
        else:
            hou.setPreference('general.nopending.val','0')
            #print('0')

    def getKeying_AutoKeyAddKeyframesOnParameterChange(self):
        return hou.getPreference('general.nopending.val')
        #print('getKeying_AutoKeyAddKeyframesOnParameterChange')


    def setKeying_AutoCommitSaveParameterChangeAtKeyframes(self,bool):
        if bool == True:
            hou.setPreference('anim.nopendingkey.val','1')
            #print('1')
        else:
            hou.setPreference('anim.nopendingkey.val','1')
            #print('0')

    def getKeying_AutoCommitSaveParameterChangeAtKeyframes(self):
        return hou.getPreference('anim.nopendingkey.val')
        #print('getKeying_AutoCommitSaveParameterChangeAtKeyframes')


    def setKeying_SetAutoAddToChannelListFlagWhenCreatingChannels(self,bool):
        if bool == True:
            hou.setPreference('anim.setautoscope.val','1')
            #print('1')
        else:
            hou.setPreference('anim.setautoscope.val','0')
            #print('0')

    def getKeying_SetAutoAddToChannelListFlagWhenCreatingChannels(self):
        return hou.getPreference('anim.setautoscope.val')
        #print('getKeying_SetAutoAddToChannelListFlagWhenCreatingChannels')



    def setKeying_SetAdditionalFirstKeyAtFrame(self,Frame):
        hou.setPreference('anim.setfirstkey.val', str(Frame))
        #print('setKeying_SetAdditionalFirstKeyAtFrame')

    def getKeying_SetAdditionalFirstKeyAtFrame(self):
        return hou.getPreference('anim.setfirstkey.val')
        #print('getKeying_SetAdditionalFirstKeyAtFrame')


    def setKeying_GlobalSetKey(self,keyNum):
        '''

        :param keyNum: 0 - Set Keys on Pending Channels,
        1 - Set Keys on All Channels,
        2 - Set Keys on Selected Channels
        :return:
        '''
        if keyNum == 0:
            hou.setPreference('anim.setkey.val', '0')
            #print('Set Keys on Pending Channels')
        elif keyNum == 1:
            hou.setPreference('anim.setkey.val', '1')
            #print('Set Keys on All Channels')
        elif keyNum == 2:
            hou.setPreference('anim.setkey.val', '2')
            #print('Set Keys on Selected Channels')


    def getKeying_GlobalSetKey(self):
        return hou.getPreference('anim.setkey.val')
        #print('getKeying_GlobalSetKey')


    def setInitialSegment_DefaultFunction(self,functions):
        '''
        :param functions: str  -   constant(),linear(),ease(),easein(),easeout(),
        easep(2),easeinp(2),easeoutp(2),match(),matchin(),matchout(),
        vmatch(),vmatchin(),vmatchout(),
        cubic(),bezier(),quintic(),spline(),qlinear()
        :return:
        '''
        hou.setPreference('anim.firstfunc.val', functions)
        #print('setInitialSegment_DefaultFunction')


    def getInitialSegment_DefaultFunction(self):
        return hou.getPreference('anim.firstfunc.val')
        #print('getInitialSegment_DefaultFunction')


    def setInitialSegment_RotationFunction(self,functions):
        '''
        :param functions: str  -   constant(),linear(),ease(),easein(),easeout(),
        easep(2),easeinp(2),easeoutp(2),match(),matchin(),matchout(),
        vmatch(),vmatchin(),vmatchout(),
        cubic(),bezier(),quintic(),spline(),qlinear()
        :return:
        '''
        hou.setPreference('anim.rotationfunc.menu',functions)
        #print('setInitialSegment_RotationFunction')

    def getInitialSegment_RotationFunction(self):
        return hou.getPreference('anim.rotationfunc.menu')
        #print('getInitialSegment_RotationFunction')


    def setAddedSegment_AutoFunction(self,bool):
        if bool == True:
            hou.setPreference('anim.autofunc.val','1')
            #print('1')
        else:
            hou.setPreference('anim.autofunc.val','0')
            #print('0')

    def getAddedSegment_AutoFunction(self):
        return hou.getPreference('anim.autofunc.val')
        #print('getAddedSegment_AutoFunction')



    def setAddedSegment_AutoFunction_Function(self,functions):
        '''
        :param functions: str  -   constant(),linear(),ease(),easein(),easeout(),
        easep(2),easeinp(2),easeoutp(2),match(),matchin(),matchout(),
        vmatch(),vmatchin(),vmatchout(),
        cubic(),bezier(),quintic(),spline(),qlinear()
        :return:
        '''

        hou.setPreference('anim.addedfunc.val', functions)
        #print('setAddedSegment_AutoFunction_Function')

    def getAddedSegment_AutoFunction_Function(self):
        return hou.getPreference('anim.addedfunc.val')
        #print('getAddedSegment_AutoFunction_Function')


    def setAddedSegment_Slope(self,slopeNum):
        '''
        :param slopeNum: 0 - Manual Slope , 1 - Manual Slope but Keep Slope Value from Existing Curve,
        2 - Automatic Slop Mode
        :return:
        '''
        hou.setPreference('anim.autoslope.val', str(slopeNum))
        #print('setAddedSegment_Slope')

    def getAddedSegment_Slope(self):
        hou.getPreference('anim.autoslope.val')
        #print('getAddedSegment_Slope')


    def setManualSlope_value(self,value):
        hou.setPreference('anim.slope.val', str(value))
        #print('setManualSlope_value')

    def getManualSlope_value(self):
        return hou.getPreference('anim.slope.val')
        #print('getManualSlope_value')


    def setHoldLastKey(self,bool):
        if bool == True:
            hou.setPreference('anim.holdlastkey.val','1')
            #print('1')
        else:
            hou.setPreference('anim.holdlastkey.val','0')
            #print('0')

    def getHoldLastKey(self):
        return hou.getPreference('anim.holdlastkey.val')
        #print('getHoldLastKey')


    def setAnimationEditorAndMotionFxViewer_UpdateChannelListWhenNodesAreSelected(self,bool):

        if bool == True:
            hou.setPreference('anim.autoupdatechannels.val','1')
            #print('1')
        else:
            hou.setPreference('anim.autoupdatechannels.val','0')
            #print('0')

    def getAnimationEditorAndMotionFxViewer_UpdateChannelListWhenNodesAreSelected(self):
        return hou.getPreference('anim.autoupdatechannels.val')
        #print('getAnimationEditorAndMotionFxViewer_UpdateChannelListWhenNodesAreSelected')


    def setAnimationEditorAndMotionFxViewer_AddParametersWithAutoAddToChannelListFlag(self,bool):

        if bool == True:
            hou.setPreference('objects.linkchanneleditor.val','1')
            #print('1')
        else:
            hou.setPreference('objects.linkchanneleditor.val','0')
            #print('0')

    def getAnimationEditorAndMotionFxViewer_AddParametersWithAutoAddToChannelListFlag(self):
        return hou.setPreference('objects.linkchanneleditor.val')
        #print('getAnimationEditorAndMotionFxViewer_AddParametersWithAutoAddToChannelListFlag')


    def setAnimationEditorAndMotionFxViewer_AddParametersWithAnimation(self,bool):
        if bool == True:
            hou.setPreference('anim.includeanim.val','1')
            #print('1')
        else:
            hou.setPreference('anim.includeanim.val','0')
            #print('0')

    def getAnimationEditorAndMotionFxViewer_AddParametersWithAnimation(self):
        return hou.getPreference('anim.includeanim.val')
        #print('getAnimationEditorAndMotionFxViewer_AddParametersWithAnimation')


    def setAnimationEditorAndMotionFxViewer_AddParametersFromDescendants(self,bool):

        if bool == True:
            hou.setPreference('anim.includechild.val','1')
            #print('1')
        else:
            hou.setPreference('anim.includechild.val','0')
            #print('0')

    def getAnimationEditorAndMotionFxViewer_AddParametersFromDescendants(self):
        return hou.getPreference('anim.includechild.val')
        #print('getAnimationEditorAndMotionFxViewer_AddParametersWithAnimation')



    def setAnimationEditorAndMotionFxViewer_AddParametersFromConstraints(self,bool):
        if bool == True:
            hou.setPreference('anim.includeconstraints.val','1')
            #print('1')
        else:
            hou.setPreference('anim.includeconstraints.val','0')
            #print('0')

    def getAnimationEditorAndMotionFxViewer_AddParametersFromConstraints(self):
        return hou.getPreference('anim.includeconstraints.val')
        #print('getAnimationEditorAndMotionFxViewer_AddParametersFromConstraints')



    def setRestChannelListSelection(self,bool):
        if bool == True:
            hou.setPreference('anim.resetchannelselection.val','1')
            #print('1')
        else:
            hou.setPreference('anim.resetchannelselection.val','0')
            #print('0')

    def getRestChannelListSelection(self):
        return hou.setPreference('anim.resetchannelselection.val')
        #print('getRestChannelListSelection')


    def setOpenAnimationEditorIfClosed(self,bool):

        if bool == True:
            hou.setPreference('objects.openchanneleditor.val', '1')
            #print('1')
        else:
            hou.setPreference('objects.openchanneleditor.val', '0')
            #print('0')

    def getOpenAnimationEditorIfClosed(self):
        return hou.getPreference('objects.openchanneleditor.val')
        #print('getOpenAnimationEditorIfClosed')


    def setFollpwChannelReferences(self,bool):
        if bool == True:
            hou.setPreference('anim.followscopedchannelreferences.val','1')
            #print('1')
        else:
            hou.setPreference('anim.followscopedchannelreferences.val', '0')
            #print('0')

    def getFollpwChannelReferences(self):
        return hou.setPreference('anim.followscopedchannelreferences.val')
        #print('getFollpwChannelReferences')


    def setUnderlineInTheParameterEditor(self,bool):

        if bool == True:
            hou.setPreference('anim.underlinescoped.val', '1')
            #print('1')
        else:
            hou.setPreference('anim.underlinescoped.val', '0')
            #print('0')

    def getUnderlineInTheParameterEditor(self):
        return hou.getPreference('anim.underlinescoped.val')
        #print('getUnderlineInTheParameterEditor')


    def setViewOverriddenParametersInMotionFxView(self,bool):
        if bool == True:
            hou.setPreference('objects.linkchopviewer.val','1')
            #print('1')
        else:
            hou.setPreference('objects.linkchopviewer.val','0')
            #print('0')

    def getViewOverriddenParametersInMotionFxView(self):
        return hou.getPreference('objects.linkchopviewer.val')
        #print('getViewOverriddenParametersInMotionFxView')



    def setUseChannelColor(self,bool):
        if bool == True:
            hou.setPreference('anim.underlinescopedcolor.val','1')
            #print('1')
        else:
            hou.setPreference('anim.underlinescopedcolor.val','0')
            #print('0')

    def getUseChannelColor(self):
        return hou.getPreference('anim.underlinescopedcolor.val')
        #print('getUseChannelColor')